package com.example.arithmeticleetcode.leetcode;

/**
 * @program: arithmetic-leetcode
 * @description:
 * @author: FangZhen
 * @create: 2020-05-12 18:20
 **/
public class Demo16 {

    public static void main(String[] args) {
        int[] arr1 = {4, 5, 8}, arr2 = {10, 9, 1, 8};
        int[] arr3 = {1, 4, 2, 3}, arr4 = {-4, -3, 6, 10, 20, 30};
        int[] arr5 = {2, 1, 100, 3}, arr6 = {-5, -2, 10, -3, 7};
        System.out.println(findTheDistanceValue(arr1, arr2, 2));
        System.out.println(findTheDistanceValue(arr3, arr4, 3));
        System.out.println(findTheDistanceValue(arr5, arr6, 6));
    }

    public static int findTheDistanceValue(int[] arr1, int[] arr2, int d) {
        int len = 0;
        for (int i : arr1) {
            boolean flag = true;
            for (int j : arr2) {
                if (Math.abs(i - j) <= d) {
                    flag = false;
                    break;
                }
            }
            if (flag) {
                len++;
            }
        }
        return len;
    }
}
